package com.meiyou.controller;

import com.meiyou.result.Result;
import com.meiyou.service.SystemService;
import com.meiyou.vo.UserAndArticleByMonthVo;
import com.meiyou.vo.UserAndArticleVo;
import com.meiyou.vo.UserByAddressVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/system")
public class SystemController {

    @Autowired
    private SystemService systemService;

    /**
     * 获取总用户数和总文章数
     *
     * @return
     */
    @GetMapping
    public Result<UserAndArticleVo> getUserAndArticleNum() {

        return Result.success(systemService.getUserAndArticleNum());
    }

    /**
     * 获取最近三个月用户数和文章数
     *
     * @return
     */
    @GetMapping("/month")
    public Result<UserAndArticleByMonthVo> getUserAndArticleNumByMonth() {

        return Result.success(systemService.getUserAndArticleNumByMonth());
    }

    /**
     * 获取每个地区的用户占比，前五
     *
     * @return
     */
    @GetMapping("/address")
    public Result<List<UserByAddressVo>> getUserByAddress() {

        return Result.success(systemService.getUserByAddress());
    }

}
